#ifndef _CURL_H
#define _CURL_H
#include <curl/curl.h>
#include <string>
#include <iostream>
using std::string;
using std::cout;
using std::endl;


class Curl
{
public:
    Curl();
    ~Curl();
    string get(const string& url);
    string post(const string &url,const string & data);
private:
    CURL* curl;
    std::string response;

    //回调函数，用于处理接收到的数据
    static size_t writeCallback(void * contents , size_t size,size_t nmemb,void *userp ){
        size_t realsize =size* nmemb;
        string * buff = static_cast<string *>(userp);
        buff->append(static_cast<char*>(contents),realsize );
        return realsize;
    }

    string preformRequest(const string & url,const string & data);
};
#endif

